//
//  UserIcon.swift
//  VO_Yuejie
//
//  Created by laichunhui on 15/12/1.
//  Copyright © 2015年 lch. All rights reserved.
//

import UIKit

class UserIcon: UIButton {

    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
        // Drawing code
    }
    */
    override init(frame: CGRect) {
        super.init(frame: frame)
       // self.setImage(UIImage(named: "sm_user_icon"), forState: .Normal)

        self.titleLabel!.textAlignment = .Center
        self.setTitleColor(UIColor.colorWith(151, green: 151, blue: 151, alpha: 1), forState: .Normal)
        self.titleLabel!.font = UIFont.systemFontOfSize(11)

    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

    
    override func layoutSubviews() {
        super.layoutSubviews()
    
        // 调整图片
        self.imageView!.y = 5
        self.imageView!.width = 48
        self.imageView!.height = self.imageView!.width
        self.imageView!.centerX = self.width * 0.5
        // 调整文字
        self.titleLabel!.x = -15
        self.titleLabel!.y = CGRectGetMaxY(self.imageView!.frame) + 5
        self.titleLabel!.width = self.width + 30
        self.titleLabel!.height = self.height - self.titleLabel!.y

    }
}
